﻿/*
版权所有：版权所有(C) 2010，刘建新
文件编号：M01_LoginInfo.cs
文件名称：LoginInfo.cs
系统编号：Z0003007
系统名称：通用办公系统
模块编号：M01
模块名称：信息发布
设计文档：IOA_M01信息发布XDE建模.mdx
完成日期：2010/12/17
作　　者：
内容摘要：表[Login_Info]对应的实体类
*/

using System;
using System.Collections;
using System.Data;


namespace Eis51.CampanyCMS.Model.BaseInfoMng
{
		/// <summary>
		/// 类 编 号：
		/// 类 名 称：LoginInfo
		/// 内容摘要：
		/// </summary>
		
		[Serializable]
		public class LoginInfo : BaseModel
		{
		#region 自动生成代码
		
			#region 重载Equals/GetHashCode
			/// <summary>
			/// 重载Equals			
			/// </summary>
			public override bool Equals (Object obj)
			{
				if (obj != null && obj is LoginInfo)
				{
					if (obj == this)
						return true;
					LoginInfo castObj = (LoginInfo)obj; 
					
					if (!this.m_Seqno.Equals(castObj.Seqno))
						return false;
						
					if (!this.m_IpAddress.Equals(castObj.IpAddress))
						return false;
						
					if (!this.m_LoginTime.Equals(castObj.LoginTime))
						return false;
						
					if (!this.m_LoginName.Equals(castObj.LoginName))
						return false;
						
					return true;
				}
				return false;
			}
			
			/// <summary>
			/// 重载GetHashCode
			/// </summary>
			public override int GetHashCode()
			{
					int hash = 0;					
					
					hash = hash <<  8;
					if ((object)m_Seqno != null)
					{
						hash = hash ^ m_Seqno.GetHashCode();
					}
						
					hash = hash <<  8;
					if ((object)m_IpAddress != null)
					{
						hash = hash ^ m_IpAddress.GetHashCode();
					}
						
					hash = hash <<  8;
					if ((object)m_LoginTime != null)
					{
						hash = hash ^ m_LoginTime.GetHashCode();
					}
						
					hash = hash <<  8;
					if ((object)m_LoginName != null)
					{
						hash = hash ^ m_LoginName.GetHashCode();
					}
						
					return hash; 
			}
			#endregion
			
			public LoginInfo()
			{
				MarkNew();
			}						
			
			public LoginInfo GetOldValue()
			{
				return OldValue as LoginInfo;
			}
		
		#region Seqno属性
			private int m_Seqno = 0;
			/// <summary>
			/// 属性名称： Seqno
			/// 内容摘要： DB列名：Seqno[]
			///            DB类型：int
			/// </summary>
			public int Seqno
			{
				get
					{
						return m_Seqno;
					}
				set
					{
						if (m_Seqno as object == null || !m_Seqno.Equals(value))
						{
							m_Seqno = value;
							MarkUpdated();
						}						
					}
			}
		#endregion
		
		#region IpAddress属性
			private string m_IpAddress = String.Empty;
			/// <summary>
			/// 属性名称： IpAddress
			/// 内容摘要： DB列名：Ip_Address[]
			///            DB类型：string
			/// </summary>
			public string IpAddress
			{
				get
					{
						return m_IpAddress;
					}
				set
					{
						if (m_IpAddress as object == null || !m_IpAddress.Equals(value))
						{
							m_IpAddress = value;
							MarkUpdated();
						}						
					}
			}
		#endregion
		
		#region LoginTime属性
			private DateTime m_LoginTime = new DateTime(1900,1,1);
			/// <summary>
			/// 属性名称： LoginTime
			/// 内容摘要： DB列名：Login_Time[]
			///            DB类型：DateTime
			/// </summary>
			public DateTime LoginTime
			{
				get
					{
						return DateTime.Parse(m_LoginTime.ToString("yyyy-MM-dd HH:mm:ss"));
					}
				set
					{
						if (m_LoginTime as object == null || !m_LoginTime.Equals(value))
						{
							m_LoginTime = value;
							MarkUpdated();
						}						
					}
			}
		#endregion
		
		#region LoginName属性
			private string m_LoginName = String.Empty;
			/// <summary>
			/// 属性名称： LoginName
			/// 内容摘要： DB列名：Login_Name[]
			///            DB类型：string
			/// </summary>
			public string LoginName
			{
				get
					{
						return m_LoginName;
					}
				set
					{
						if (m_LoginName as object == null || !m_LoginName.Equals(value))
						{
							m_LoginName = value;
							MarkUpdated();
						}						
					}
			}
		#endregion
		
		#region static CreateDataTable/FillDataRow/DataRow2Obj/Dt2Objs/FillDataTable
			/// <summary>
			/// 得到实体对应的DataTable
			/// </summary>
			/// <param name="tableName">表名</param>
			/// <param name="cne">列名映射选择:DB列名或属性名</param>
			/// <returns>生成的DataTable</returns>
			static public DataTable CreateDataTable(string tableName,ColumnNameEnum cne)
			{
				DataTable dtResult = new DataTable(tableName);
			
				if (cne == ColumnNameEnum.DBName)
				{
					dtResult.Columns.Add(new DataColumn("Seqno",typeof(int)));
					dtResult.Columns.Add(new DataColumn("Ip_Address",typeof(string)));
					dtResult.Columns.Add(new DataColumn("Login_Time",typeof(DateTime)));
					dtResult.Columns.Add(new DataColumn("Login_Name",typeof(string)));
				}
				else if (cne == ColumnNameEnum.PropertyName)
				{
					dtResult.Columns.Add(new DataColumn("Seqno",typeof(int)));
					dtResult.Columns.Add(new DataColumn("IpAddress",typeof(string)));
					dtResult.Columns.Add(new DataColumn("LoginTime",typeof(DateTime)));
					dtResult.Columns.Add(new DataColumn("LoginName",typeof(string)));
				}
				return dtResult;
			}
			
			/// <summary>
			/// 得到实体对应的DataTable
			/// </summary>
			/// <param name="cne">列名映射选择:DB列名或属性名</param>
			/// <returns>生成的DataTable</returns>
			static public DataTable CreateDataTable(ColumnNameEnum cne)
			{
				return CreateDataTable(null,cne);
			}

			/// <summary>
			/// 得到实体对应的DataTable(默认列名映射为属性名)
			/// </summary>
			/// <returns>生成的DataTable</returns>
			static public DataTable CreateDataTable()
			{
				return CreateDataTable(ColumnNameEnum.PropertyName);
			}
			
			/// <summary>
			/// 用当前对象值填充DaraRow
			/// </summary>
			/// <param name="dr">由CreateTable生成的DataTable通过NewRow得到的DataRow对象</param>
			/// <param name="cne">dr的列名映射方式:DB列名或属性名</param>
			public void FillDataRow(DataRow dr,ColumnNameEnum cne)
			{
				if (dr == null)
				{
					throw new ArgumentNullException("dr");
				}
				if (ColumnNameEnum.DBName == cne)
				{
					dr["Seqno"] = this.Seqno;
					dr["Ip_Address"] = this.IpAddress;
					dr["Login_Time"] = this.LoginTime;
					dr["Login_Name"] = this.LoginName;
				}
				else if (ColumnNameEnum.PropertyName == cne)
				{
					dr["Seqno"] = this.Seqno;
					dr["IpAddress"] = this.IpAddress;
					dr["LoginTime"] = this.LoginTime;
					dr["LoginName"] = this.LoginName;					
				}
			}
			
			/// <summary>
			/// 用当前对象值填充DaraRow(默认列名映射为属性名)
			/// </summary>
			/// <param name="dr">由CreateTable生成的DataTable通过NewRow得到的DataRow对象</param>
			public void FillDataRow(DataRow dr)
			{
				this.FillDataRow(dr,ColumnNameEnum.PropertyName);
			}
			
			/// <summary>
			/// 将DataRow转换成LoginInfo对象
			/// </summary>
			/// <param name="dr">由CreateTable生成的DataTable通过NewRow得到的DataRow对象</param>
			/// <param name="cne">dr的列名映射方式:DB列名或属性名</param>
			/// <returns>LoginInfo对象</returns>
			public static LoginInfo Dr2Obj(DataRow dr,ColumnNameEnum cne)
			{
				if (dr == null)
				{
					throw new ArgumentNullException("dr");
				}
				LoginInfo obj = new LoginInfo();
				if (ColumnNameEnum.DBName == cne)
				{
					obj.Seqno = (dr["Seqno"] == Convert.DBNull) ? 0  : (int)Convert.ChangeType(dr["Seqno"],typeof(int));
					obj.IpAddress = (dr["Ip_Address"] == Convert.DBNull) ? null  : (string)Convert.ChangeType(dr["Ip_Address"],typeof(string));
					obj.LoginTime = (dr["Login_Time"] == Convert.DBNull) ? new DateTime(1900,1,1)  : (DateTime)Convert.ChangeType(dr["Login_Time"],typeof(DateTime));
					obj.LoginName = (dr["Login_Name"] == Convert.DBNull) ? null  : (string)Convert.ChangeType(dr["Login_Name"],typeof(string));
				}
				else if (ColumnNameEnum.PropertyName == cne)
				{
					obj.Seqno = (dr["Seqno"] == Convert.DBNull) ? 0  : (int)Convert.ChangeType(dr["Seqno"],typeof(int));
					obj.IpAddress = (dr["IpAddress"] == Convert.DBNull) ? null  : (string)Convert.ChangeType(dr["IpAddress"],typeof(string));
					obj.LoginTime = (dr["LoginTime"] == Convert.DBNull) ? new DateTime(1900,1,1)  : (DateTime)Convert.ChangeType(dr["LoginTime"],typeof(DateTime));
					obj.LoginName = (dr["LoginName"] == Convert.DBNull) ? null  : (string)Convert.ChangeType(dr["LoginName"],typeof(string));		
				}
				
				return obj;
			}
			
			/// <summary>
			/// 将DataRow转换成LoginInfo对象(默认列名映射为属性名)
			/// </summary>
			/// <returns>LoginInfo对象</returns>
			public static LoginInfo Dr2Obj(DataRow dr)
			{
				return Dr2Obj(dr,ColumnNameEnum.DBName);
			}
			
			/// <summary>
			/// 将DataTabe转换成的LoginInfo对象集合
			/// </summary>
			/// <param name="dt">由CreateTable生成的DataTable</param>
			/// <param name="cne">dt的列名映射方式:DB列名或属性名</param>
			/// <returns>LoginInfo对象的集合</returns>
			public static IList Dt2Objs(DataTable dt,ColumnNameEnum cne)
			{
				if (dt == null)
				{
					throw new ArgumentNullException("dt");
				}
				
				ArrayList alResult = new ArrayList();
				
				foreach(DataRow dr in dt.Rows)
				{
					alResult.Add(Dr2Obj(dr,cne));
				}
				
				return alResult;
			}

			/// <summary>
			/// 将DataTabe转换成的LoginInfo对象集合(默认列名映射为属性名)
			/// </summary>
			/// <param name="dt">由CreateTable生成的DataTable</param>
			/// <returns>LoginInfo对象的集合</returns>
			public static IList Dt2Objs(DataTable dt)
			{
				return Dt2Objs(dt,ColumnNameEnum.PropertyName);
			}
			
			/// <summary>
			/// 用objs的LoginInfo对象集合填充DataTable
			/// </summary>
			/// <param name="dt">由CreateTable生成的DataTable</param>
			/// <param name="objs">LoginInfo对象集合</param>
			/// <param name="cne">dt的列名映射方式:DB列名或属性名</param>
			public static void FillDataTable(DataTable dt,IList objs,ColumnNameEnum cne)
			{
				if (dt == null)
				{
					throw new ArgumentNullException("dt");
				}
				if (objs == null)
				{
					throw new ArgumentNullException("objs");
				}
				
				foreach(LoginInfo obj in objs)
				{
					DataRow dr = dt.NewRow();
					obj.FillDataRow(dr,cne);
					dt.Rows.Add(dr);
				}
			}

			/// <summary>
			/// 用objs的LoginInfo对象集合填充DataTable(默认列名映射为属性名)
			/// </summary>
			/// <param name="dt">由CreateTable生成的DataTable</param>
			/// <param name="objs">LoginInfo对象集合</param>
			public static void FillDataTable(DataTable dt,IList objs)
			{
				FillDataTable(dt,objs,ColumnNameEnum.PropertyName);
			}
		#endregion
		
		/// <summary>
		/// 取消编辑,恢复到上次有效调用BeginEdit前的状态,并清空保留值
		/// </summary>
		public override void CancelEdit()
		{
			LoginInfo old = this.OldValue as LoginInfo;
			if (old != null)
			{
					this.Seqno = old.Seqno;
					this.IpAddress = old.IpAddress;
					this.LoginTime = old.LoginTime;
					this.LoginName = old.LoginName;				
				this.OldValue = null;
			}
		}
		
		
		
		
		#region LoginInfo实体的内部Key类
			/// <summary>
			/// LoginInfo实体的Key类
			/// </summary>
			public sealed class Key
			{
		
				private int m_Seqno;
				public int Seqno
				{
 					get 
					{ 
						 return m_Seqno; 
					}
					set 
					{ 
						m_Seqno = value;
					}
				}
		
				public Key(int pSeqno)
				{
					m_Seqno=pSeqno;

				}
			}
		#endregion
			/// <summary>
			/// 得到实体LoginInfo的PK
			/// </summary>
			public Key GetKey()
			{
				return new Key(Seqno);				
			}
			
				
		#endregion
	}
}
